<template>
  <div class="login">
    <div class="window animate__animated animate__bounceInLeft">
      <div class="img">
        <img src="../../assets/img/window_img3.jpg" opacity="0.5" alt="" />
      </div>
      <p>欢迎回来...</p>
      <el-input placeholder="请输入用户名" v-model="name" clearable> </el-input>
      <el-input
        id="psd"
        placeholder="请输入密码"
        v-model="psd"
        show-password
      ></el-input>
      <el-button type="primary" @click="add">登录</el-button>
      <p>
        <span>忘记密码？</span>
        <span @click="forget">没有账号...</span>
      </p>
    </div>
  </div>
</template>

<script>
// 引入的url接口地址
import ceshi from "../../assets/axios/login/index";

export default {
  data() {
    return {
      //   账号
      name: "",
      // 密码
      psd: "",
    };
  },

  methods: {
    // 跳转到注册
    forget() {
      this.$router.push({ path: "/register" });
    },
    // 登录请求
    add() {
      let user = `name=${this.name}&password=${this.psd}`;
      this.$axios.get(ceshi.ceshi + user).then((res) => {
        if (res.data) {
          this.$router.push({ path: "/home" });
        } else {
          alert("账户名或密码不正确");
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.login {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  background:url("../../assets/img/login_img3.png") no-repeat center center ;
  background-size: 100% 100%;
  background-color: aqua;
  position: absolute;
  top: 0;
  left: 0;
  .window {
    width: 400px;
    height: 500px;
    position: fixed;
    top: 20%;
    right: 7%;
    padding-top: 30px;
    .img {
      display: flex;
      opacity: 1;
      position: absolute;
      width: 400px;
      height: 500px;
      z-index: -999;
      right: 20px;
      overflow: hidden;
      img {
        margin: auto;
        margin-left: -120px;
        // opacity: 0.8;
      }
    }
    p:nth-child(2) {
      font-size: 25px;
      width: 150px;
      height: 50px;
      margin: 0;
      font-weight: 900;
      margin-left: -20px;
      margin-top: 10px;
    }
    p:nth-child(6) {
      margin-top: 150px;
      span:nth-child(1) {
        &:hover {
          color: blue;
          text-decoration: blue 1px solid underline;
        }
        cursor: pointer;
      }
      span:nth-child(2) {
        &:hover {
          color: blue;
          text-decoration: blue 1px solid underline;
        }
        cursor: pointer;
      }
    }
    .el-input {
      width: 300px;
      line-height: 80px !important;
    }
    .el-button {
      display: block;
      border-radius: 20px;
      width: 200px;
      margin: 20px auto;
    }
  }
}
.el-main {
  line-height: 50px;
}
</style>